/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vn.support.system;

import java.util.logging.Level;
import java.util.logging.Logger;
import vn.support.connection.Connection;
import vn.support.connection.RequestConnection;
import vn.support.core.dto.DataObject;
import vn.support.core.dto.SessionData;

/**
 *
 * @author nttuyen
 */
public class SystemShutdown extends Thread {
    @Override
    public void run() {
        DataObject system = SystemProperties.getData();
        SessionData session = system.get(SessionData.class.getName());
        SystemProperties.shutdown();
        if(session != null && session.getSessionId() != null && !"".equals(session.getSessionId())) {
            Connection connection = new RequestConnection();
            DataObject data = new DataObject(Connection.LOGOUT_ACTION);
            data.set("sessionid", session.getSessionId());
            connection.execute(data);
        }
        try {
            Thread.sleep(5000);
        } catch (InterruptedException ex) {
            Logger.getLogger(SystemShutdown.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
